<?php
declare(strict_types=1);

namespace App\Controller\Admin\V1\Sys;

use App\Controller\Admin\AdminController;
use App\Repositories\SysConfigRepository;

class ConfigController extends AdminController
{
    public function get()
    {
        $type=$this->request->input('type');
        $search = [
            [
                'field' => 'type',
                'value' => $type
            ]
        ];
        $return = SysConfigRepository::getInstance()->getList('*',$search,[]);
        $setting=[];
        if($return){
            foreach ($return as $key=>$value){
                $setting[$value['name']] = $value['value'];
            }
        }
        return $this->response->success($setting);
    }

    public function store()
    {
        $datas = $this->request->all();
        $return = SysConfigRepository::getInstance()->store($datas);
        return $this->response->success($return);
    }
}